/*     */ package com.zimbra.qa.unittest;
/*     */ 
/*     */ import com.google.common.collect.Lists;
/*     */ import com.zimbra.common.localconfig.DebugConfig;
/*     */ import com.zimbra.common.localconfig.KnownKey;
/*     */ import com.zimbra.common.localconfig.LC;
/*     */ import com.zimbra.common.util.CliUtil;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.Log.Level;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.Server;
/*     */ import com.zimbra.cs.account.accesscontrol.RightManager;
/*     */ import com.zimbra.cs.account.ldap.LdapDIT;
/*     */ import com.zimbra.cs.account.ldap.LdapProv;
/*     */ import com.zimbra.cs.account.ldap.LdapProvisioning;
/*     */ import com.zimbra.cs.ldap.LdapClient;
/*     */ import com.zimbra.cs.ldap.LdapServerType;
/*     */ import com.zimbra.cs.ldap.LdapUsage;
/*     */ import com.zimbra.cs.ldap.ZLdapContext;
/*     */ import com.zimbra.cs.ldap.ZLdapFilter;
/*     */ import com.zimbra.cs.ldap.ZLdapFilterFactory;
/*     */ import com.zimbra.cs.ldap.ZSearchControls;
/*     */ import com.zimbra.cs.ldap.ZSearchResultEntry;
/*     */ import com.zimbra.cs.ldap.ZSearchResultEnumeration;
/*     */ import com.zimbra.cs.ldap.ZSearchScope;
/*     */ import com.zimbra.cs.ldap.unboundid.InMemoryLdapServer;
/*     */ import com.zimbra.cs.ldap.unboundid.UBIDLdapClient;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestAccountLockout;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestAutoProvision;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapBinary;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapConnection;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapHelper;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvAccount;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvAlias;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvAttrCallback;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvCos;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvDIT;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvDataSource;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvDistributionList;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvDomain;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvDynamicGroup;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvEntry;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvExternalLdapAuth;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvGal;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvGlobalConfig;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvGlobalGrant;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvIdentity;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvMimeType;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvMisc;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvModifyAttrs;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvRenameDomain;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvSearchDirectory;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvServer;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvSignature;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvXMPPComponent;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapProvZimlet;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapUpgrade;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapUtil;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapZLdapContext;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapZLdapFilter;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestLdapZMutableEntry;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestProvAlias;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestProvAttr;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestProvCallbackAvailableZimlets;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestProvIDN;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestProvValidator;
/*     */ import com.zimbra.qa.unittest.prov.ldap.TestProvZimbraId;
/*     */ import com.zimbra.qa.unittest.prov.soap.TestACLUserRights;
/*     */ import com.zimbra.qa.unittest.prov.soap.TestDelegatedDL;
/*     */ import com.zimbra.qa.unittest.prov.soap.TestSearchGal;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintStream;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.HashSet;
/*     */ import java.util.List;
/*     */ import java.util.Set;
/*     */ import org.junit.Assert;
/*     */ import org.junit.BeforeClass;
/*     */ import org.junit.runner.JUnitCore;
/*     */ import org.junit.runner.Result;
/*     */ import org.junit.runner.notification.Failure;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class TestLdap
/*     */ {
/*     */   private static final String TEST_LDAP_BASE_DOMAIN = "unittest";
/*     */   private static boolean perJVMInited;
/*     */   private static String useInMemoryLdapServerOverride;
/*     */   private static final String ATOM_CHARS = "!#$%&'*+-/=?^_`{|}~";
/*     */   private static final String DOT_ATOM_CHARS = ".!#$%&'*+-/=?^_`{|}~";
/*     */   
/*     */   static
/*     */   {
/* 109 */     perJVMInited = false;
/*     */     
/*     */ 
/*     */ 
/* 113 */     useInMemoryLdapServerOverride = null;
/*     */     
/*     */ 
/*     */ 
/* 117 */     boolean assertsEnabled = false;
/* 118 */     assert ((assertsEnabled = 1) != 0);
/*     */     
/* 120 */     if (!assertsEnabled) {
/* 121 */       throw new RuntimeException("Asserts must be enabled!!!");
/*     */     }
/*     */   }
/*     */   
/*     */   static void modifyLocalConfig(String key, String value) throws Exception
/*     */   {
/* 127 */     Process process = null;
/*     */     try {
/* 129 */       String command = "/opt/zimbra/bin/zmlocalconfig -e " + key + "=" + value;
/* 130 */       System.out.println(command);
/* 131 */       process = Runtime.getRuntime().exec(command);
/*     */     } catch (IOException e) {
/* 133 */       e.printStackTrace();
/* 134 */       throw e;
/*     */     }
/*     */     
/*     */     try
/*     */     {
/* 139 */       int exitCode = process.waitFor();
/* 140 */       Assert.assertEquals(0L, exitCode);
/*     */     } catch (InterruptedException e) {
/* 142 */       e.printStackTrace();
/* 143 */       throw e;
/*     */     }
/*     */   }
/*     */   
/*     */   static enum TestConfig
/*     */   {
/* 149 */     UBID(UBIDLdapClient.class, LdapProvisioning.class);
/*     */     
/* 151 */     private static TestConfig currentTestConfig = null;
/*     */     private Class ldapClientClass;
/*     */     private Class ldapProvClass;
/*     */     
/*     */     private TestConfig(Class ldapClientClass, Class ldapProvClass)
/*     */     {
/* 157 */       this.ldapClientClass = ldapClientClass;
/* 158 */       this.ldapProvClass = ldapProvClass;
/*     */     }
/*     */     
/*     */     static synchronized void useConfig(TestConfig config) throws Exception {
/* 162 */       if (currentTestConfig != null) {
/* 163 */         Assert.fail("TestConfig.useConfig can only be called once per JVM");
/*     */       }
/*     */       
/* 166 */       currentTestConfig = config;
/*     */       
/*     */ 
/*     */ 
/*     */ 
/* 171 */       if (config.ldapClientClass != null) {
/* 172 */         TestLdap.modifyLocalConfig(LC.zimbra_class_ldap_client.key(), config.ldapClientClass.getCanonicalName());
/*     */       }
/*     */       else {
/* 175 */         TestLdap.modifyLocalConfig(LC.zimbra_class_ldap_client.key(), "");
/*     */       }
/* 177 */       TestLdap.modifyLocalConfig(LC.zimbra_class_provisioning.key(), config.ldapProvClass.getCanonicalName());
/* 178 */       LC.reload();
/*     */     }
/*     */     
/*     */     static synchronized TestConfig getCurrentTestConfig() {
/* 182 */       if (currentTestConfig == null) {
/* 183 */         Assert.fail("TestConfig has not been initialized");
/*     */       }
/*     */       
/* 186 */       return currentTestConfig;
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public static void deleteEntireBranch(String domainName)
/*     */     throws Exception
/*     */   {
/* 197 */     String[] parts = domainName.split("\\.");
/* 198 */     String[] dns = ((LdapProv)Provisioning.getInstance()).getDIT().domainToDNs(parts);
/* 199 */     String topMostRDN = dns[(dns.length - 1)];
/* 200 */     deleteEntireBranchByDN(topMostRDN);
/*     */     
/* 202 */     cleanupAll();
/*     */   }
/*     */   
/*     */   private static void cleanupAll() throws Exception {
/* 206 */     deleteAllNonDefaultCoses();
/* 207 */     deleteAllNonDefaultServers();
/* 208 */     deleteAllXMPPComponents();
/*     */   }
/*     */   
/*     */   private static void deleteAllNonDefaultCoses() throws Exception {
/* 212 */     LdapDIT dit = ((LdapProv)Provisioning.getInstance()).getDIT();
/* 213 */     String cosBaseDN = dit.cosBaseDN();
/*     */     
/* 215 */     Set<String> defaultCosDN = new HashSet();
/* 216 */     defaultCosDN.add(dit.cosNametoDN("default"));
/* 217 */     defaultCosDN.add(dit.cosNametoDN("defaultExternal"));
/*     */     
/* 219 */     deleteAllChildrenUnderDN(cosBaseDN, defaultCosDN);
/*     */   }
/*     */   
/*     */   private static void deleteAllNonDefaultServers() throws Exception {
/* 223 */     LdapProv ldapProv = LdapProv.getInst();
/* 224 */     LdapDIT dit = ldapProv.getDIT();
/* 225 */     String serverBaseDN = dit.serverBaseDN();
/*     */     
/* 227 */     Set<String> defaultServerDN = new HashSet();
/* 228 */     defaultServerDN.add(dit.serverNameToDN(ldapProv.getLocalServer().getName()));
/*     */     
/* 230 */     deleteAllChildrenUnderDN(serverBaseDN, defaultServerDN);
/*     */   }
/*     */   
/*     */   private static void deleteAllXMPPComponents() throws Exception {
/* 234 */     String xmppBaseDN = ((LdapProv)Provisioning.getInstance()).getDIT().xmppcomponentBaseDN();
/* 235 */     deleteAllChildrenUnderDN(xmppBaseDN, null);
/*     */   }
/*     */   
/*     */   private static void deleteEntireBranchByDN(String dn)
/*     */     throws Exception
/*     */   {
/* 241 */     ZLdapContext zlc = null;
/*     */     try
/*     */     {
/* 244 */       zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UNITTEST);
/* 245 */       deleteEntireBranch(zlc, dn);
/*     */     } finally {
/* 247 */       LdapClient.closeContext(zlc);
/*     */     }
/*     */   }
/*     */   
/*     */   private static void deleteAllChildrenUnderDN(String dn, Set<String> ignoreDNs)
/*     */     throws Exception
/*     */   {
/* 254 */     ZLdapContext zlc = null;
/*     */     try {
/* 256 */       zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UNITTEST);
/* 257 */       List<String> childrenDNs = getDirectChildrenDNs(zlc, dn);
/* 258 */       for (String childDN : childrenDNs) {
/* 259 */         if ((ignoreDNs == null) || (!ignoreDNs.contains(childDN))) {
/* 260 */           deleteEntireBranch(zlc, childDN);
/*     */         }
/*     */       }
/*     */     } finally {
/* 264 */       LdapClient.closeContext(zlc);
/*     */     }
/*     */   }
/*     */   
/*     */   private static void deleteEntireBranch(ZLdapContext zlc, String dn)
/*     */     throws Exception
/*     */   {
/* 271 */     if (isLeaf(zlc, dn)) {
/* 272 */       deleteEntry(dn);
/* 273 */       return;
/*     */     }
/*     */     
/* 276 */     List<String> childrenDNs = getDirectChildrenDNs(zlc, dn);
/* 277 */     for (String childDN : childrenDNs) {
/* 278 */       deleteEntireBranch(zlc, childDN);
/*     */     }
/* 280 */     deleteEntry(dn);
/*     */   }
/*     */   
/*     */   private static void deleteEntry(String dn) throws Exception {
/* 284 */     ZLdapContext zlc = null;
/*     */     try {
/* 286 */       zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UNITTEST);
/* 287 */       zlc.deleteEntry(dn);
/*     */     } finally {
/* 289 */       LdapClient.closeContext(zlc);
/*     */     }
/*     */   }
/*     */   
/*     */   private static boolean isLeaf(ZLdapContext zlc, String dn) throws Exception {
/* 294 */     return getDirectChildrenDNs(zlc, dn).size() == 0;
/*     */   }
/*     */   
/*     */   private static List<String> getDirectChildrenDNs(ZLdapContext zlc, String dn) throws Exception {
/* 298 */     List<String> childrenDNs = new ArrayList();
/*     */     
/* 300 */     ZLdapFilter filter = ZLdapFilterFactory.getInstance().anyEntry();
/*     */     
/* 302 */     ZSearchControls searchControls = ZSearchControls.createSearchControls(ZSearchScope.SEARCH_SCOPE_ONELEVEL, 0, new String[] { "objectClass" });
/*     */     
/*     */ 
/*     */ 
/* 306 */     ZSearchResultEnumeration sr = zlc.searchDir(dn, filter, searchControls);
/* 307 */     while (sr.hasMore()) {
/* 308 */       ZSearchResultEntry entry = sr.next();
/* 309 */       childrenDNs.add(entry.getDN());
/*     */     }
/* 311 */     sr.close();
/*     */     
/* 313 */     return childrenDNs;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   private static String makeRFC2253Name(String name, boolean wantTrailingBlank)
/*     */   {
/* 342 */     String LEADING_CHARS = "#";
/* 343 */     String TRAILING_CHARS = " ";
/* 344 */     String BACKSLASH_ESCAPED_CHARS = "# ,+\"\\<>;";
/* 345 */     String UNICODE_CHARS = "中文";
/*     */     
/* 347 */     if (wantTrailingBlank) {
/* 348 */       return LEADING_CHARS + BACKSLASH_ESCAPED_CHARS + ".!#$%&'*+-/=?^_`{|}~" + UNICODE_CHARS + "---" + name + TRAILING_CHARS;
/*     */     }
/* 350 */     return LEADING_CHARS + BACKSLASH_ESCAPED_CHARS + ".!#$%&'*+-/=?^_`{|}~" + UNICODE_CHARS + "---" + name;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   private static String makeRFC2253NameEmailLocalPart(String name)
/*     */   {
/* 359 */     String LEADING_CHAR = "#";
/* 360 */     return LEADING_CHAR + ".!#$%&'*+-/=?^_`{|}~" + "---" + name;
/*     */   }
/*     */   
/*     */   private static String makeRFC2253NameDomainName(String name) {
/* 364 */     String UNICODE_CHARS = "中文";
/*     */     
/*     */ 
/* 367 */     return UNICODE_CHARS + "---" + name;
/*     */   }
/*     */   
/*     */   static String makeAccountNameLocalPart(String localPart) {
/* 371 */     return makeRFC2253NameEmailLocalPart(localPart);
/*     */   }
/*     */   
/*     */   static String makeAliasNameLocalPart(String localPart) {
/* 375 */     return makeRFC2253NameEmailLocalPart(localPart);
/*     */   }
/*     */   
/*     */   static String makeCosName(String name) {
/* 379 */     return makeRFC2253Name(name, false);
/*     */   }
/*     */   
/*     */ 
/*     */   static String makeDataSourceName(String name)
/*     */   {
/* 385 */     return makeRFC2253Name(name, true);
/*     */   }
/*     */   
/*     */   static String makeDLNameLocalPart(String localPart) {
/* 389 */     return makeRFC2253NameEmailLocalPart(localPart);
/*     */   }
/*     */   
/*     */   static String makeDomainName(String name) {
/* 393 */     return makeRFC2253NameDomainName(name);
/*     */   }
/*     */   
/*     */ 
/*     */   static String makeIdentityName(String name)
/*     */   {
/* 399 */     return makeRFC2253Name(name, true);
/*     */   }
/*     */   
/*     */   static String makeServerName(String name) {
/* 403 */     return makeRFC2253Name(name, false);
/*     */   }
/*     */   
/*     */   static String makeSignatureName(String name) {
/* 407 */     return makeRFC2253Name(name, false);
/*     */   }
/*     */   
/*     */   static String makeXMPPName(String name) {
/* 411 */     return makeRFC2253Name(name, false);
/*     */   }
/*     */   
/*     */   static String makeZimletName(String name) {
/* 415 */     return makeRFC2253Name(name, false);
/*     */   }
/*     */   
/*     */ 
/* 419 */   private static boolean batchMode = false;
/*     */   
/*     */ 
/*     */   private static void runTests(JUnitCore junit, TestConfig testConfig)
/*     */     throws Exception
/*     */   {
/* 425 */     batchMode = true;
/*     */     
/* 427 */     initPerJVM(testConfig);
/*     */     
/* 429 */     Date startTime = new Date();
/* 430 */     SimpleDateFormat dateFmt = new SimpleDateFormat("HH:mm:ss");
/* 431 */     System.out.println("TestLdap started at: " + dateFmt.format(startTime));
/*     */     
/* 433 */     if (testConfig == TestConfig.UBID) {}
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 438 */     List<Class> classes = Lists.newArrayList();
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 443 */     classes.add(TestLdapHelper.class);
/* 444 */     classes.add(TestLdapConnection.class);
/* 445 */     classes.add(TestLdapProvAccount.class);
/* 446 */     classes.add(TestLdapProvAlias.class);
/* 447 */     classes.add(TestLdapProvAttrCallback.class);
/* 448 */     classes.add(TestAutoProvision.class);
/* 449 */     classes.add(TestLdapProvCos.class);
/* 450 */     classes.add(TestLdapProvDataSource.class);
/* 451 */     classes.add(TestLdapProvDistributionList.class);
/* 452 */     classes.add(TestLdapProvDIT.class);
/* 453 */     classes.add(TestLdapProvDomain.class);
/* 454 */     classes.add(TestLdapProvDynamicGroup.class);
/* 455 */     classes.add(TestLdapProvEntry.class);
/* 456 */     classes.add(TestLdapProvExternalLdapAuth.class);
/* 457 */     classes.add(TestLdapProvGal.class);
/* 458 */     classes.add(TestLdapProvGlobalConfig.class);
/* 459 */     classes.add(TestLdapProvGlobalGrant.class);
/* 460 */     classes.add(TestLdapProvIdentity.class);
/* 461 */     classes.add(TestLdapProvMimeType.class);
/* 462 */     classes.add(TestLdapProvMisc.class);
/* 463 */     classes.add(TestLdapProvModifyAttrs.class);
/* 464 */     classes.add(TestLdapProvRenameDomain.class);
/* 465 */     classes.add(TestLdapProvServer.class);
/* 466 */     classes.add(TestLdapProvSignature.class);
/* 467 */     classes.add(TestLdapProvSearchDirectory.class);
/* 468 */     classes.add(TestLdapProvXMPPComponent.class);
/* 469 */     classes.add(TestLdapProvZimlet.class);
/* 470 */     classes.add(TestLdapUtil.class);
/* 471 */     classes.add(TestLdapUpgrade.class);
/* 472 */     classes.add(TestLdapZLdapContext.class);
/* 473 */     classes.add(TestLdapZLdapFilter.class);
/* 474 */     classes.add(TestLdapZMutableEntry.class);
/*     */     
/*     */ 
/*     */ 
/* 478 */     classes.add(TestDelegatedDL.class);
/*     */     
/*     */ 
/* 481 */     classes.add(TestAccountLockout.class);
/*     */     
/* 483 */     classes.add(TestACLUserRights.class);
/* 484 */     classes.add(TestBuildInfo.class);
/* 485 */     classes.add(TestLdapBinary.class);
/* 486 */     classes.add(TestLdapUtil.class);
/* 487 */     classes.add(TestProvAlias.class);
/* 488 */     classes.add(TestProvAttr.class);
/* 489 */     classes.add(TestProvCallbackAvailableZimlets.class);
/* 490 */     classes.add(TestProvIDN.class);
/* 491 */     classes.add(TestProvValidator.class);
/* 492 */     classes.add(TestProvZimbraId.class);
/* 493 */     classes.add(TestSearchGal.class);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 523 */     Class[] classArray = (Class[])classes.toArray(new Class[classes.size()]);
/* 524 */     Result result = junit.run(classArray);
/*     */     
/* 526 */     System.out.println("===== Number of Failures: " + result.getFailureCount());
/* 527 */     List<Failure> failures = result.getFailures();
/* 528 */     for (Failure failure : failures) {
/* 529 */       System.out.println(failure.toString());
/* 530 */       System.out.println();
/*     */     }
/* 532 */     System.out.println();
/*     */     
/*     */ 
/* 535 */     Date endTime = new Date();
/* 536 */     System.out.println("TestLdap ended at:   " + dateFmt.format(endTime));
/*     */     
/* 538 */     long elapsedMills = endTime.getTime() - startTime.getTime();
/* 539 */     long minutes = elapsedMills / 60000L;
/* 540 */     long seconds = elapsedMills / 1000L;
/* 541 */     long secs = seconds - minutes * 60L;
/* 542 */     System.out.println();
/* 543 */     System.out.println("Elapsed time: " + minutes + " mins " + secs + " secs");
/*     */   }
/*     */   
/*     */   private static void initPerJVM(TestConfig testConfig) throws Exception
/*     */   {
/* 548 */     if (perJVMInited) {
/* 549 */       return;
/*     */     }
/* 551 */     perJVMInited = true;
/*     */     
/* 553 */     CliUtil.toolSetup(Log.Level.error.name());
/* 554 */     ZimbraLog.test.setLevel(Log.Level.info);
/* 555 */     ZimbraLog.autoprov.setLevel(Log.Level.debug);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 587 */     if (useInMemoryLdapServerOverride != null) {
/* 588 */       boolean useInMemoryLdapServer = Boolean.parseBoolean(useInMemoryLdapServerOverride);
/*     */       
/*     */ 
/* 591 */       KnownKey key = new KnownKey("debug_use_in_memory_ldap_server", useInMemoryLdapServerOverride);
/*     */       
/* 593 */       if (DebugConfig.useInMemoryLdapServer != useInMemoryLdapServer) {
/* 594 */         System.out.println("useInMemoryLdapServerOverride is " + useInMemoryLdapServerOverride + " but LC key debug_use_in_memory_ldap_server is " + key.value() + ".  Remove the value from LC key.");
/*     */         
/*     */ 
/* 597 */         Assert.fail();
/*     */       }
/*     */     }
/* 600 */     ZimbraLog.test.info("useInMemoryLdapServer = " + InMemoryLdapServer.isOn());
/*     */     
/* 602 */     RightManager.getInstance(true);
/* 603 */     TestConfig.useConfig(testConfig);
/*     */     
/* 605 */     cleanupAll();
/*     */   }
/*     */   
/*     */   @BeforeClass
/*     */   public static void beforeClass() throws Exception
/*     */   {
/* 611 */     if (batchMode) {
/* 612 */       return;
/*     */     }
/*     */     
/* 615 */     TestConfig testConfig = TestConfig.UBID;
/*     */     
/* 617 */     initPerJVM(testConfig);
/*     */   }
/*     */   
/*     */   static String baseDomainName(Class<? extends TestLdap> klass) {
/* 621 */     return klass.getName().toLowerCase() + "." + "unittest";
/*     */   }
/*     */   
/*     */   static TestConfig getCurrentTestConfig() {
/* 625 */     return TestConfig.getCurrentTestConfig();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public static void main(String[] args)
/*     */     throws Exception
/*     */   {
/* 638 */     JUnitCore junit = new JUnitCore();
/*     */     
/* 640 */     junit.addListener(new TestLogger());
/*     */     
/* 642 */     TestConfig.useConfig(TestConfig.UBID);
/*     */     
/*     */ 
/*     */ 
/* 646 */     System.out.println();
/* 647 */     System.out.println("=== Finished ===");
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestLdap.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */